import 'dart:convert';

T? asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }
  return null;
}

class AcGoodsModel {
  AcGoodsModel({
    this.goodsId,
    this.code,
    this.icon,
    this.type,
    this.subType,
    this.discount,
    this.originalPrice,
    this.price,
    this.exchangeCoin,
    this.originalPriceRupee,
    this.priceRupee,
    this.localPaymentPriceRupee,
    this.isPromotion,
    this.localPayOriginalPrice,
    this.localPayPrice,
  });

  factory AcGoodsModel.fromJson(Map<String, dynamic> json) => AcGoodsModel(
    goodsId: asT<String?>(json['goodsId']),
    code: asT<String?>(json['code']),
    icon: asT<String?>(json['icon']),
    type: asT<String?>(json['type']),
    subType: asT<int?>(json['subType']),
    discount: asT<double?>(json['discount']),
    originalPrice: asT<double?>(json['originalPrice']),
    price: asT<double?>(json['price']),
    exchangeCoin: asT<int?>(json['exchangeCoin']),
    originalPriceRupee: asT<double?>(json['originalPriceRupee']),
    priceRupee: asT<double?>(json['priceRupee']),
    localPaymentPriceRupee: asT<double?>(json['localPaymentPriceRupee']),
    isPromotion: asT<bool?>(json['isPromotion']),
    localPayOriginalPrice: asT<int?>(json['localPayOriginalPrice']),
    localPayPrice: asT<int?>(json['localPayPrice']),
  );

  String? goodsId;
  String? code;
  String? icon;
  String? type;
  int? subType;
  double? discount;
  double? originalPrice;
  double? price;
  int? exchangeCoin;
  double? originalPriceRupee;
  double? priceRupee;
  double? localPaymentPriceRupee;
  bool? isPromotion;
  int? localPayOriginalPrice;
  int? localPayPrice;

  @override
  String toString() {
    return jsonEncode(this);
  }

  Map<String, dynamic> toJson() => <String, dynamic>{
    'goodsId': goodsId,
    'code': code,
    'icon': icon,
    'type': type,
    'subType': subType,
    'discount': discount,
    'originalPrice': originalPrice,
    'price': price,
    'exchangeCoin': exchangeCoin,
    'originalPriceRupee': originalPriceRupee,
    'priceRupee': priceRupee,
    'localPaymentPriceRupee': localPaymentPriceRupee,
    'isPromotion': isPromotion,
    'localPayOriginalPrice': localPayOriginalPrice,
    'localPayPrice': localPayPrice,
  };
}
